<template>
  <div id="basicLayout">
    <a-layout style="min-height: 100vh">
      <!-- 根据路由判断是否显示导航栏，登录和注册页面不显示 -->
      <a-layout-header class="header" v-if="!isLoginOrRegisterPage">
        <GlobalHeader />
      </a-layout-header>
      <!-- 在登录和注册页面的左上角显示logo -->
      <div class="login-page-logo" v-else @click="goToHome">
        <img src="../assets/logo.png" alt="沐云图" class="logo-img" />
      </div>
      <a-layout-content class="content">
        <router-view />
      </a-layout-content>
      <a-layout-footer class="footer">
        <a href="https://www.codefather.cn" target="_blank"> 沐云图 by 胖沐沐&少吃糖 </a>
      </a-layout-footer>
    </a-layout>
  </div>
</template>

<script setup lang="ts">
import GlobalHeader from '@/components/GlobalHeader.vue'
import GlobalSider from "@/components/GlobalSider.vue";
import { computed } from 'vue';
import { useRoute, useRouter } from 'vue-router';

const route = useRoute();
const router = useRouter();

// 判断是否为登录或注册页面
const isLoginOrRegisterPage = computed(() => {
  return route.path.startsWith('/user/login') || route.path.startsWith('/user/register');
});

// 点击logo返回首页
const goToHome = () => {
  router.push('/');
};
</script>

<style scoped>
#basicLayout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#basicLayout .header {
  padding: 0;
  background: #ffffff;
  color: unset;
  border-bottom: 1px solid #f0f0f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

#basicLayout .content {
  padding: 24px;
  background: #fafafa;
  flex: 1;
  display: flex;
  flex-direction: column;
}

#basicLayout .footer {
  background: #ffffff;
  padding: 24px;
  text-align: center;
  border-top: 1px solid #f0f0f0;
  color: #999999;
  font-size: 14px;
  flex-shrink: 0;
}

/* 登录页面的logo样式 */
.login-page-logo {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1001;
}

.logo-img {
  height: 40px;
  width: auto;
  cursor: pointer;
}

/* 内容区域优化 */
:deep(.ant-layout) {
  background: transparent;
}

:deep(.ant-layout-content) {
  background: transparent;
}

/* 滚动条优化 */
:deep(*)::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

:deep(*)::-webkit-scrollbar-track {
  background: #f0f0f0;
}

:deep(*)::-webkit-scrollbar-thumb {
  background: #c0c0c0;
  border-radius: 3px;
}

:deep(*)::-webkit-scrollbar-thumb:hover {
  background: #999999;
}
</style>
